package cn.keniykey.mc.landterritory.vault;

import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.plugin.Plugin;

public abstract class Perm {
	private static Perm perm;
	
	static {
		Plugin vault = Bukkit.getPluginManager().getPlugin("Vault");
		try {
			if (vault != null) perm = new PermVault();
		}catch(Exception ex) {}
		if(perm == null) perm = new PermNull();
	}
	public static Perm getPerm() {
		return perm;
	}
	
	public abstract boolean isEnable();
	public boolean hasPermission(World world,OfflinePlayer p,String per) {
		if (world != null) {
			return this.hasPermission(world.getName(), p, per);
		}
		return this.hasPermission("", p, per);
	}
	public abstract boolean hasPermission(String world,OfflinePlayer p,String per);
	public boolean addPlayerPermission(World world,OfflinePlayer p,String per) {
		if (world != null) {
			return this.addPlayerPermission(world.getName(), p, per);
		}
		return this.addPlayerPermission("", p, per);
	}
	public abstract boolean addPlayerPermission(String world,OfflinePlayer p,String per);
	public boolean removePlayerPermission(World world,OfflinePlayer p,String per) {
		if (world != null) {
			return this.removePlayerPermission(world.getName(), p, per);
		}
		return this.removePlayerPermission("", p, per);
	}
	public abstract boolean removePlayerPermission(String world,OfflinePlayer p,String per);
	public boolean addGroupPermission(World world,String group,String per) {
		if (world != null) {
			return this.addGroupPermission(world.getName(), group, per);
		}
		return this.addGroupPermission("", group, per);
	}
	public abstract boolean addGroupPermission(String world,String group,String per);
	public boolean removeGroupPermission(World world,String group,String per) {
		if (world != null) {
			return this.removeGroupPermission(world.getName(), group, per);
		}
		return this.removeGroupPermission("", group, per);
	}
	public abstract boolean removeGroupPermission(String world,String group,String per);
}